﻿using stdCall.MyUtils;
using System;
using System.Collections;

namespace stdCall.Models
{
    /// <summary>
    /// 学生管理类，学生表为静态Hash表
    /// </summary>
    class StudentsManager
    {
        private static Hashtable students = new Hashtable();

        public static Hashtable Students
        {
            get { return StudentsManager.students; }
            set { StudentsManager.students = value; }
        }

        /// <summary>
        /// 根据学号获取学生
        /// </summary>
        /// <param name="studentNum"></param>
        /// <returns></returns>
        public Student getStudentByNum(String studentNum)
        {
         //   Student student=null;

            return (Student)students[studentNum];
        }

        /// <summary>
        /// 获取所有学生，返回排序后的ArrayList
        /// </summary>
        /// <returns></returns>
        public ArrayList getAllStudents()
        {
            ArrayList stds = new ArrayList();
            foreach (DictionaryEntry de in students)
            {
                stds.Add((Student)(de.Value));
            }
            stds.Sort(new StudentCompare());
            return stds;
        }

        /// <summary>
        /// 添加一个学生
        /// </summary>
        /// <param name="studentNum"></param>
        /// <param name="name"></param>
        public void addStudent(String studentNum , String name)
        {
            students.Add(studentNum, new Student(studentNum, name));
        }

        /// <summary>
        /// 添加一个学生
        /// </summary>
        /// <param name="studentNum"></param>
        /// <param name="name"></param>
        /// <param name="unluckyNum">被点名次数</param>
        public void addStudent(String studentNum, String name,int unluckyNum)
        {
            students.Add(studentNum, new Student(studentNum, name, unluckyNum));
        }
      
// 
//         public Student getAPoorStdFairly()
//         {
//             Student student = null;
// 
//             return student;
//         }


//         public bool loadStudents()
//         {
//             bool flag = false;
//             return flag;
//         }

    }
}
